package com.treetao.union.web.controller.mall;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

import com.treetao.union.db.model.CommonSetting;
import com.treetao.union.db.model.vo.RestResponse;
import com.treetao.union.db.service.CommonSettingService;
import com.treetao.union.web.constant.Constants;

@Controller
@RequestMapping(Constants.AMIND_PREFIX + "/common-setting")
public class CommonSettingController {
	@Autowired
	private CommonSettingService commonSettingService;
	
	@GetMapping("page")
	public String topage() {
		 return "/admin/common-setting/page";
	}
	
	@GetMapping("detail")
	public @ResponseBody RestResponse getsetting(@RequestParam("type")String type) {
		return RestResponse.success(commonSettingService.getCommonSetting(type));
	}
	
	@PostMapping("update")
	public @ResponseBody RestResponse update(CommonSetting setting) {
		return RestResponse.success(commonSettingService.updateCommonSetting(setting));
	}
}
